#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{
    int fd = open("test.log", O_CREAT | O_WRONLY | O_APPEND, 0666);
    dup2(fd, 1);
    std::cout << "test\n";
    close(fd);
    return 0;
}